package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DesensitizeUtils;
import com.ruoyi.common.utils.Func;
import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.ExtIdentityResultMapper;
import com.ruoyi.bizsys.domain.ExtIdentityResult;
import com.ruoyi.bizsys.service.IExtIdentityResultService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 身份验证数据Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class ExtIdentityResultServiceImpl extends ServiceImpl<ExtIdentityResultMapper,ExtIdentityResult> implements IExtIdentityResultService {

    /**
     * 查询身份验证数据
     *
     * @param id 身份验证数据ID
     * @return 身份验证数据
     */
    @Override
    public ExtIdentityResult selectExtIdentityResultById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询身份验证数据列表
     *
     * @param extIdentityResult 身份验证数据
     * @return 身份验证数据
     */
    @Override
    public List<ExtIdentityResult> selectExtIdentityResultList(ExtIdentityResult extIdentityResult) {
        return this.list(new QueryWrapper<>(extIdentityResult).last("order by id desc"));
    }

    /**
     * 新增身份验证数据
     *
     * @param extIdentityResult 身份验证数据
     * @return 结果
     */
            @Override
    public int insertExtIdentityResult(ExtIdentityResult extIdentityResult) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                extIdentityResult.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(extIdentityResult);
    }

    /**
     * 修改身份验证数据
     *
     * @param extIdentityResult 身份验证数据
     * @return 结果
     */
            @Override
    public int updateExtIdentityResult(ExtIdentityResult extIdentityResult) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        extIdentityResult.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(extIdentityResult);
    }

    /**
     * 批量删除身份验证数据
     *
     * @param ids 需要删除的身份验证数据ID
     * @return 结果
     */
            @Override
    public int deleteExtIdentityResultByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除身份验证数据信息
     *
     * @param id 身份验证数据ID
     * @return 结果
     */
    @Override
    public int deleteExtIdentityResultById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public String getIdentityDesensitizePhones(Long realNameLogId) {
        String identityPhones = baseMapper.getIdentityPhones(realNameLogId);
        if (Func.isEmpty(identityPhones)){
            return "";
        }
        return DesensitizeUtils.arrayRight(identityPhones.split(","), 4, ",");
    }

}
